<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            思路：nums[i]为可跳跃长度，那么我们需要计算出当前下标可到达的范围cover,即下标加nums[i]
            每次能走的就是那个最大范围。如果当前范围大于nums.length 那么说明可以到达
            */
            var canJump = function (nums) {
                if (nums.length == 1) return true
                let cover = nums[0]
                for (let i = 1; i <= cover; i++) {
                    cover = Math.max(cover, nums[i] + i)
                    if (cover >= nums.length - 1) {
                        return true
                    }
                }
                return false
            }
        </script>
    </body>
</html>
